$(function () {
    hljs.highlightAll();
    $("#btn_submit").on("click", function (event) {
        event.preventDefault();
        var $this = $(this);
        var uid = $this.attr("data-uid");
        if (!uid || uid == "") {
            alert("请先登录");
            window.location = "/login/";
            return;
        }
        var pid = $this.attr("data-pid");
        var content = $('#comment_textarea').val();
        myajax.post({
            url: "/comment/publish/",
            data: {"content": content, "user_id": uid, "post_id": pid},
            success: function (result) {
                if (result['code'] == 200) {
                    window.location.reload();
                } else {
                    alert(result['message']);
                }
            }
        });
    });
});